package cn.softgame.jserver.connector.data;

import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;


public class StringType implements Linkable {
	private String content=null;
	private int msgType;
	private ByteBuffer byteBuffer=null;
	
	public StringType(int msgType){
		this.msgType=msgType;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Override
	public void accept(QueueWorker worker) throws Exception {
		worker.run(msgType, this);
	}

	@Override
	public OutputStream getOutputStream() {
		OutputStream os = null;
		try {
			// 将String转换成ByteArrayOutputStream
			os = DataTypeHelper.writeString(content);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return os;
	}

	@Override
	public void setInputStream(InputStream in) {
		try {
			// 将ByteArrayInputStream转换成String
			this.content = DataTypeHelper.getString(in);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
